//
//  ViewController.swift
//  Yolan123
//
//  Created by Fenly on 2018/4/26.
//  Copyright © 2018年 Cotte. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    lazy var spinButtonView1: SpinButtonView = SpinButtonView.instanteFormNib()
    lazy var spinButtonView2: SpinButtonView = SpinButtonView.instanteFormNib()
    lazy var dataAnimationInfoView: DataConfirmationAnimationInfoView = DataConfirmationAnimationInfoView.instanteFormNib()
    lazy var stretchButtonView: StretchButtonView = StretchButtonView.instanteFormNib()
    
    var loadingView: LoadingView = LoadingView()
    var startButton: UIButton = UIButton()
    var isHiddenAnimation: Bool = false
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        setupView()
        
        setupDataAnimationInfoView()
    }
    
    private func setupDataAnimationInfoView() {
        view.addSubview(dataAnimationInfoView)
        dataAnimationInfoView.frame = CGRect(x: 500, y: 400, width: 400, height: 325)
    }
    
    
    
    private func setupView () {
        view.addSubview(spinButtonView1)
        spinButtonView1.frame = CGRect(x: 0, y: 100, width: 300, height: 300)
        spinButtonView1.setupSpinButtonView(text: "旋转", canScale: false)
        
        view.addSubview(spinButtonView2)
        spinButtonView2.frame = CGRect(x: 350, y: 100, width: 200, height: 200)
        spinButtonView2.setupSpinButtonView(text: "缩放", canScale: false)
        
        
        view.addSubview(loadingView)
        loadingView.loadUI(loadText: "努力加载中...")
        loadingView.frame = CGRect(x: 300, y: 100, width: 100, height: 25)
        
        view.addSubview(startButton)
        startButton.frame = CGRect(x: 0, y: UIScreen.main.bounds.size.height - 100, width: 100, height: 50)
        startButton.setTitleColor(.black, for: .normal)
        startButton.setTitle("加载动画", for: .normal)
        startButton.addTarget(self, action: #selector(tappedClick), for: .touchUpInside)
        
        
        // 伸缩按钮
        stretchButtonView.frame = CGRect(x: 300, y: 500, width: 200, height: 200)
        view.addSubview(stretchButtonView)
        stretchButtonView.setStretchButtonView(eightDirection: true)
        
        
        let redview = UIView.init(frame: CGRect(x: 500, y: 400, width: 10, height: 10))
        redview.backgroundColor = UIColor.red
        view.addSubview(redview)
        
        
        let lineView = CGLineView.init(frame: CGRect(x: 600, y: 100, width: 200, height: 100))
        view.addSubview(lineView)
        
    }
    
    @objc private func tappedClick() {
//        dataAnimationInfoView.startAnimation()
//        if isHiddenAnimation {
//            dataAnimationInfoView.hideAnimation()
//        } else {
//
//            dataAnimationInfoView.setupInitAnimationInfoViewPoint(at: CGPoint(x: 500, y: 400), position: .rightTop)
//
//            }
//        isHiddenAnimation = !isHiddenAnimation
        
//        stretchButtonView.setStretchButtonView(eightDirection: false)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

